package com.bat.client.service;

import com.bat.vo.AsyncVo;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Service;

import java.util.concurrent.Future;

@Slf4j
@Service
@Data
public class AsyncService {

    @Async
    public Future<AsyncVo> age(AsyncVo vo){
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        log.info("age");
        vo.setAge(10);
        return new AsyncResult<>(vo);
    }
    @Async
    public Future<AsyncVo> name(AsyncVo vo){
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        log.info("name");
        vo.setName("异步name");
        return new AsyncResult<>(vo);
    }
    @Async
    public Future<AsyncVo> nickName(AsyncVo vo){
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        log.info("nickname");
        vo.setNickName("nickname");
        return new AsyncResult<>(vo);
    }

}
